#include "newprojectdialog.h"
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QPushButton>
#include "ui_newprojectdialog.h"

NewProjectDialog::NewProjectDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::NewProjectDialog)
{
    ui->setupUi(this);

    // 假设你有一个QDialogButtonBox命名为buttonBox，它是对话框布局的一部分
    // 你可以通过findChild来访问OK按钮
    QPushButton *okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
    okButton->setText("确定");
    QPushButton *cancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel);
    cancelButton->setText("取消");

    if (okButton) {
        //okButton->setEnabled(false); // 禁用OK按钮
    }
}

NewProjectDialog::~NewProjectDialog()
{
    delete ui;
}

void NewProjectDialog::on_pushButtonSelectDirectory_clicked()
{
    QString folderPath = QFileDialog::getExistingDirectory(nullptr,
                                                           QObject::tr("Open Directory"),
                                                           QDir::homePath());

    if (!folderPath.isEmpty()) {
        // 用户选择了一个文件夹，folderPath 就是所选文件夹的路径
        // 在这里处理选中的文件夹
        ui->lineEditPathname->setText(folderPath);
    }
}

void NewProjectDialog::on_lineEdit_textEdited(const QString &arg1)
{
    m_strProjectname = ui->lineEditProjectname->text();
}

void NewProjectDialog::on_lineEditPathname_textChanged(const QString &arg1)
{
    m_strPathname = ui->lineEditPathname->text();
}

void NewProjectDialog::on_lineEditProjectname_textChanged(const QString &arg1)
{
    m_strProjectname = ui->lineEditProjectname->text();
}
